/**
* @Description: WoShop商城
* @Author: 梧桐
* @Copyright: 武汉一一零七科技有限公司©版权所有
* @Link: www.wo-shop.net
* @Contact: QQ:2487937004
*/
<template>
	<view>
		<view class="inputWrap">
			<u-form-item :label="$t('手机号')" label-width="150">
				<u-input v-model="phone" :placeholder="$t('请输入手机号')" maxlength="11" disabled />
			</u-form-item>
			<u-form-item :label="$t('验证码')" prop="code" label-width="150">
				<u-input :placeholder="$t('请输入验证码')" v-model="code" maxlength="6" type="text"></u-input>
				<u-verification-code seconds="60" ref="uCode" @change="codeChange"></u-verification-code>
				<u-button slot="right" size="mini" @click="getCode">{{clickText}}</u-button>
			</u-form-item>
			<u-form-item :label="$t('支付密码')" label-width="150">
				<u-input type="password" v-model="paypwd" :placeholder="$t('请输入支付密码')" maxlength="11" />
			</u-form-item>
			<u-form-item :label="$t('确认密码')" label-width="150">
				<u-input type="password" v-model="paypwd2" :placeholder="$t('请确认支付密码')" maxlength="11" />
			</u-form-item>

			<u-button type="error" mode="plain" shape="circle" class="u-m-t-40" @click="confirmClick">{{$t('确定')}}</u-button>

		</view>
	</view>
</template>

<script>
	let courr = 5;
	let setId = null;
	export default {

		data() {
			return {
				phone: "",
				paypwd: "",
				paypwd2: "",
				code: "",
				clickText: ""
			};
		},
		onLoad() {
			this.getUserPhone();
			this.clickText = this.$t('获取验证码')
		},
		copmputed: {
			returnPwd() {
				return this.paypwd === this.paypwd2
			}
		},

		methods: {
			codeChange(text) {
				this.clickText = text;
			},
			getCode() {
				this.$http.getSmsCode({
					phone: this.phone,
					type: 5
				}).then(res => {
					if (res.status == 200) {
						this.$refs.uCode.start();
					}
				});

			},

			confirmClick() {
				if (this.code == "") {
					this.$toast(this.$t('请输入验证码'));
					return false;
				}
				if (this.paypwd == "") {
					this.$toast(this.$t('请输入密码'));
					return false;
				}
				if (this.paypwd !== this.paypwd2) {
					return this.$toast(this.$t('两次输入的密码不一致'));

				}

				this.$http.setPayPwd({
						code: this.code,
						phone: this.phone,
						pay_pwd: this.paypwd
					})
					.then(res => {
						
						if (res.status == 200) {
							this.$toast(res.mess);
							setTimeout(() => {
								this.$u.route({
									url: "/pagesB/setting/setting",
									type: "back"
								});
							}, 1500);
						}

					});
			},
			getUserPhone() {
				this.$http.getUserPhone().then(res => {
					if (res.status == 200) {
						this.phone = res.data.phone;
					}
				});
			}
		}
	};
</script>
<style lang="scss" scoped>
	@import '~uview-ui/index.scss';

	.inputWrap {
		background-color: #fff;
		padding: 30upx;
	}

	.input {
		height: 80upx;
		margin: 20upx 0;
	}

	.sendcoder {
		font-size: 24upx;
		color: #ec4949;
		margin-left: 20upx;
	}

	/deep/ uni-view {
		line-height: 2.4;
	}
</style>
